package com.qiankan.qmsj;

import android.content.Context;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;


public class AppPrefs {
    private static AppPrefs instance;
    private final SharedPreferences prefs;

    AppPrefs(Context context) {
        prefs = PreferenceManager.getDefaultSharedPreferences(context);
    }

    public static synchronized AppPrefs getInstance(Context context) {
        if (instance == null) {
            instance = new AppPrefs(context);
        }
        return instance;
    }

    public String getVersionCode() {
        return prefs.getString("versionCode", "");
    }

    public void saveVersionCode() {
        prefs.edit().putString("versionCode", BuildConfig.VERSION_CODE + "").apply();
    }

    public void cleanAll() {
        prefs.edit().clear().apply();
        saveVersionCode();
    }
}